home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / ams__l~1.zoo / include / mobilesp.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-25  |  2.1 KB  |  78 lines

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. //  This file is part of the Atari Machine Specific Library,
  4. //  and is Copyright 1992 by Warwick W. Allison.
  5. //
  6. //  You are free to copy and modify these sources, provided you acknowledge
  7. //  the origin by retaining this notice, and adhere to the conditions
  8. //  described in the file COPYING.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11.  
  12. #ifndef _MobileSprite_h
  13. #define _MobileSprite_h
  14.  
  15. #include "Sprite.h"
  16.  
  17. enum BoundaryEffect { Bounce, Wrap, Stop, Watch };
  18.  
  19. const short HitNorth=1;
  20. const short HitSouth=2;
  21. const short HitEast=4;
  22. const short HitWest=8;
  23.  
  24. class MobileSprite : public Sprite
  25. {
  26. public:
  27.     MobileSprite(Incarnation **Them,int Count);
  28.     MobileSprite(Incarnation *OnlyOne);
  29.     MobileSprite(short maxinca);
  30.     MobileSprite(const char *filename);
  31.     MobileSprite(Sprite& Copy);
  32.  
  33.     void Accelerate(int, int);
  34.     bool Stationary() { return (!xi && !yi); }
  35.     void Speed(int, int);
  36.     void XSpeed(int);
  37.     void YSpeed(int);
  38.     int XSpeed();
  39.     int YSpeed();
  40.     void Range(int, int, int, int);
  41.  
  42.     short Move(); // Efftected Edges returned
  43.  
  44.     void Unmove();    // Just undo the move
  45.     void Rebound(short Walls);    // Undo and rebound against given walls
  46.  
  47.     void Frictate(short fric);
  48.     void AtBoundary(BoundaryEffect, short Bouncy=256);
  49.     void AtBoundary(BoundaryEffect North,
  50.             BoundaryEffect South,
  51.             BoundaryEffect East,
  52.             BoundaryEffect West, short Bouncy=256);
  53.  
  54. private:
  55.     int    xi,yi;
  56.     int    Bounciness;
  57.     int    MinX;
  58.     int    MinY;
  59.     int    MaxX;
  60.     int    MaxY;
  61.     BoundaryEffect AtEdge[4];
  62. };
  63.  
  64.  
  65.  
  66. inline void    MobileSprite::Range(int minx, int miny, int maxx, int maxy)
  67.             { MinX=minx; MaxX=maxx; MinY=miny; MaxY=maxy; }
  68. inline void    MobileSprite::Speed(int x, int y) { xi=x; yi=y; }
  69. inline void    MobileSprite::XSpeed(int x) { xi=x; }
  70. inline void    MobileSprite::YSpeed(int y) { yi=y; }
  71. inline int MobileSprite::XSpeed() { return xi; }
  72. inline int MobileSprite::YSpeed() { return yi; }
  73. inline void    MobileSprite::Accelerate(int x, int y) { xi+=x; yi+=y; }
  74. inline void    MobileSprite::Unmove() { MoveBy(-xi,-yi); }
  75. inline void    MobileSprite::Frictate(short f) { f=256-f; xi=xi*f/256; yi=yi*f/256; }
  76.  
  77. #endif
  78.